package adv.np.pViaggianti.view.gwt.client.views;

import adv.np.pViaggianti.view.gwt.client.authentication.AuthenticationInfo;
import adv.np.pViaggianti.view.gwt.client.authentication.AuthorizationProvider;
import adv.np.pViaggianti.view.gwt.client.authentication.UserInfo;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * <p>
 * Il pannello che riassume i dati dell'utente loggato, e che permette di
 * scegliere un altro utente temporaneo.
 * </p>
 * 
 * @author Giovanni Dall'Oglio Risso
 */
public class LoggedUserPanel {

	private static Canvas userInfoPanel = null;
	
	public static Canvas getUserInfoPanel() {
		if (userInfoPanel == null)
			userInfoPanel = createUserInfoPanel();		
		return userInfoPanel;
	}
	
	private static Canvas createUserInfoPanel() {
		VLayout vertPanel = new VLayout();
         Label label = new Label();  
         label.setHeight("10%");  
         label.setPadding(10);  
         label.setAlign(Alignment.LEFT);  
         label.setValign(VerticalAlignment.CENTER);  

         UserInfo uinfo = AuthorizationProvider.getAuthInfo().getUserInfo();
         
         label.setContents(
        		 "<i>" + uinfo.getName() 
					+ " " + uinfo.getSurname() +
					" [" + uinfo.getUserName() + 
					"]</i> - [<b>" + "RAGIONERIA CONT." + "</b>]");  
		         
         vertPanel.setHeight("10%");
		 vertPanel.addMember(label);
		
		return vertPanel;
	}
	
}
